{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>编辑优惠券</h5>
                </div>
                <div class="ibox-content layui-form">
                    <div class="layui-row layui-col-space10 layui-form-item ">
                        <input type="hidden" name="id" value="{$id}">
                        <!--<div class="layui-form-item layui-col-md-offset1 layui-col-md8">-->
                        <!--<label class="layui-form-label">兑换码：</label>-->
                        <!--<div class="layui-input-block">-->
                        <!--<input type="text" name="coupon_code" lay-verify="required" placeholder="兑换码" class="layui-input ">-->
                        <!--</div>-->
                        <!--</div>-->

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">名称：</label>
                            <div class="layui-input-block">
                                <input type="text" name="coupon_name" value="{$data.coupon_name}" lay-verify="required" placeholder="名称" class="layui-input ">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">缩略图：</label>
                            <input type="hidden" name="coupon_image" value="{$data.coupon_image}" id="lay-img" lay-verify="image">
                            <div class="layui-input-block">
                                <div id="lay-upload">上传图片</div>
                                <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                    预览图：
                                    <div class="layui-upload-list" id="lay-list">
                                        <img class="layui-append-img" src="{$data.coupon_image}" onerror="this.src='/static/admin/images/no_img.jpg'">
                                    </div>
                                </blockquote>
                            </div>
                        </div>

                        <!--<div class="layui-form-item layui-col-md-offset1 layui-col-md8">-->
                        <!--<label class="layui-form-label">数量：</label>-->
                        <!--<div class="layui-input-block">-->
                        <!--<input type="text" name="coupon_num" lay-verify="required" placeholder="数量" class="layui-input ">-->
                        <!--</div>-->
                        <!--</div>-->

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                        <label class="layui-form-label">兑换价格：</label>
                        <div class="layui-input-block">
                        <input type="text" name="coupon_price" value="{$data.coupon_price}" lay-verify="required" placeholder="输入兑换所需平台币" class="layui-input ">
                        </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">优惠券有效期开始时间：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="coupon_start" value="{$data.coupon_start}" lay-verify="required" placeholder="优惠券有效期开始时间" class="layui-input test-item">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">优惠券有效期结束时间：</label>
                            <div class="layui-input-inline">
                                <input type="text"  name="coupon_end" value="{$data.coupon_end}" lay-verify="required" placeholder="优惠券有效期结束时间" class="layui-input test-item">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">领取有效期开始时间：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="coupon_use_start" value="{$data.coupon_use_start}" lay-verify="required" placeholder="领取有效期开始时间" class="layui-input test-item">
                            </div>
                        </div>

                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">领取有效期结束时间：</label>
                            <div class="layui-input-inline">
                                <input type="text"  name="coupon_use_end" value="{$data.coupon_use_end}" lay-verify="required" placeholder="领取有效期结束时间" class="layui-input test-item">
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <label class="layui-form-label">供应商：</label>
                            <div class="layui-input-block">
                                <select name="f_id" xm-select="select3"  xm-select-radio="" lay-verify="required" xm-select-search="" xm-select-search-type="dl">
                                    {volist name="realm" id="vo"}
                                    <option value="{$vo['supplier_id']}" {if $data.f_id == $vo.supplier_id}selected{/if}>{$vo['supplier_name']}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>
                        <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit="" lay-filter="component-form-element">编辑
                                </button>
                                <button class="layui-btn layui-btn-primary" onclick="history.go(-1)">关闭</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    wk.uploadImg({size:5,type:'png,jpg,jpeg',url:"{:url('Upload/upload')}",domain:""});
    layui.use(['form','upload','layedit','laydate'], function() {
        var form = layui.form;
        form.verify({
            editor:function(value,item){
                if(editor.txt.html() == '<p><br></p>'){
                    return '请填写内容';
                }
            }
        });
        form.on('submit(component-form-element)', function (data) {
            $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
            $.ajax({
                url:"{:url('update')}",
                type:'post',
                dataType:'json',
                data:data.field,
                success:function(res){
                    if (res.code == 200) {
                        wk.success(res.msg,"{:url('Shop/index')}")
                    } else {
                        wk.error(res.msg,'','$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\');');
                    }
                }
            })
        });

        var laydate = layui.laydate;
        //同时绑定多个
        lay('.test-item').each(function(){
            laydate.render({
                elem: this
                ,format:'yyyy-MM-dd HH:mm:ss'
                ,type:'datetime'
                ,trigger: 'click'
            });
        });

    });
</script>

</body>
</html>
